<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var arr = [{ name: "lisi" }, { name: "wangwu" }];
        /**
         * array object string boolean number
        */
        function deepClone(obj) {
            let result;
            if (obj instanceof Array) {
                result = [];
            } else if (typeof obj == 'object') {
                result = {};
            } else {
                // 如果是初始值 直接返回
                return obj
            }
            for (let key in obj) {
                result[key] = deepClone(obj[key]);
            }
            return result;
        }
        var newArr = deepClone(arr);
        arr[0].name = 'react';
        console.log(newArr);
    </script>
</body>

</html>